//===================================================================================
// $$
//
// Coder: Code Milker v1.0
// 0 - EntityName
// 1 - Properties
//===================================================================================


namespace App.Domain.Handlers {
    using System;
    using App.Data;
    using App.Domain.Contracts;
    using App.Domain.Models;

    public class CreateRecruiter {
        private readonly IRecruiterRepository _recruiterRepository;

        public CreateRecruiter(IRecruiterRepository recruiterRepository) {
            _recruiterRepository = recruiterRepository;
        }

        public void Execute(ICreateRecruiterCommand recruiterForm) {
            if (recruiterForm == null)
                throw new ArgumentNullException("recruiterForm");

            try {
                var recruiter = recruiterForm.ConvertToEntity();
                _recruiterRepository.Create(recruiter);
            }
            catch (InvalidOperationException ex) {
                throw new BusinessServicesException("UnableToCreateVehicleExceptionMessage", ex);
            }
        }
    }
}
